//
//  Transport.swift
//  Automobile
//
//  Created by erkebulan elzhan on 7/22/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.


import UIKit

struct CarItem {
    var image: UIImage
    var name: String
    var type: TransportType
    
    static var readyItems:[CarItem] = [
        CarItem(image: UIImage(named: "6")!, name: "Мотоциклы", type: .moto),
        CarItem(image: UIImage(named: "5")!, name: "Скутеры", type: .moto),
        CarItem(image: UIImage(named: "4")!, name: "Мотозвезды", type: .moto),
        
        CarItem(image: UIImage(named: "1")!, name: "Автобусы", type: .komtrans),
        CarItem(image: UIImage(named: "2")!, name: "Грузовики", type: .komtrans),
        CarItem(image: UIImage(named: "3")!, name: "Легкий коммерческий", type: .komtrans)
    ]
}

/// Transportation type

enum TransportType: String, CaseIterable {
    case legkovye = "Легковые"
    case komtrans = "Комтранс"
    case moto = "Мото"
    
    static func fromRawValue (_ raw: String) -> TransportType {
        return TransportType.allCases.first {
            $0.rawValue == raw
            }!
    }
    
    static func getId (_ type: TransportType) -> Int {
        switch type {
            case .komtrans:
                return 1
            case .moto:
                return 3
            case .legkovye:
                return 2
        }
    }
    
    static func getExt(_ type: TransportType) -> Int {
        switch type {
            case .komtrans:
                return 3
            case .moto:
                return 2
            case .legkovye:
                return 1
        }
    }
}



